package com.bjpowernode.boss.web.controller;

import com.bjpowernode.boss.web.model.dto.LoginResultDto;
import com.bjpowernode.boss.web.model.query.LoginQuery;
import com.bjpowernode.boss.web.model.response.Result;
import com.bjpowernode.boss.web.service.AdminService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AdminController {
@Resource
    private AdminService adminService;
//参数验证使用 Bean Validation
    @PostMapping("/operitor/access")
    public Result adminToken(@RequestBody @Validated LoginQuery loginQuery) {
//        调用service查询数据库
        LoginResultDto loginResultDto = adminService.login(loginQuery);
//        返回包含了LoginResultDto的result对象
        return Result.success(loginResultDto);
    }
}
